/*
 * Copyright rgil2010
 * All rights reserved
 */

package com.test.gui.swing.components.frame;

import com.test.gui.swing.components.button.BtnCmdApply;
import com.test.gui.swing.components.button.BtnCmdCancel;
import com.test.gui.swing.components.button.BtnCmdOk;
import com.test.gui.swing.components.dialog.DlgBoxError;
import com.test.gui.swing.components.panel.*;
import com.test.jdbc.Def;
import com.test.jdbc.connection.ConAddAnm;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


/**
 *
 * @author user
 */
public class FrmNewItmAnm extends FrmNewItmAbs implements ActionListener{
    public FrmNewItmAnm() throws Exception
    {
        this.lst_ = (ActionListener) this;
        this.pnl = new PnlNewItmAnm(lst_);
        
        this.setSize(600, 260);
        this.setTitle("Animal");
        this.add(pnl);
    }
    protected void _close_(){
        this.dispose();
    }

    protected boolean _doJob() throws Exception{
        ConAddAnm con = new ConAddAnm();
        con.setValues(
        this.pnl.getIdentiteNom(),
        this.pnl.getIdentiteSexe(),
        this.pnl.getIdProprietaire(),
        this.pnl.getCastre(),
        this.pnl.getEspece(),
        this.pnl.getRace(),
        this.pnl.getIdentiteDateNaissance(),
        this.pnl.getIdentiteDateMort());
        
        return con.doJob();
    }

    public void actionPerformed(ActionEvent e){
        if(e.getSource() instanceof BtnCmdApply){
                try {
                    _doJob();
                }
                catch (Exception ex) {
                    ex.printStackTrace();
                    DlgBoxError dlg = new DlgBoxError(ex.getMessage());
                }
            }
            else if (e.getSource() instanceof BtnCmdOk){
                try {
                    if(_doJob()) {
                        _close_();
                    }
                }
                catch (Exception ex) {
                    ex.printStackTrace();
                    DlgBoxError dlg = new DlgBoxError(ex.getMessage());
                }
            }
            else if (e.getSource() instanceof BtnCmdCancel) {
               _close_();
            }
    }

    private PnlNewItmAnm pnl;
    protected ActionListener lst_=null;


}

